import 'package:flutter/material.dart';

import 'Chart.dart';
import 'MainPage.dart';
import 'Match.dart';
import 'Me.dart';

class MainSelectPages extends StatefulWidget {
  const MainSelectPages({super.key});

  @override
  State<StatefulWidget> createState() {
    return _MainSelectPagesState();
  }
}

class _MainSelectPagesState extends State<MainSelectPages> {
  final List<BottomNavigationBarItem> bottomNavItems = [
    const BottomNavigationBarItem(
      backgroundColor: Colors.blue,
      icon: Icon(Icons.home),
      label: "首页",
    ),
    const BottomNavigationBarItem(
      backgroundColor: Colors.green,
      icon: Icon(Icons.message),
      label: "消息",
    ),
    const BottomNavigationBarItem(
      backgroundColor: Colors.amber,
      icon: Icon(Icons.shopping_cart),
      label: '购物车',
    ),
    const BottomNavigationBarItem(
      backgroundColor: Colors.red,
      icon: Icon(Icons.person),
      label: "个人中心",
    ),
  ];
  final pages = [
    const MyHomePage(),
    const MatchPage(),
    const MePage(),
    const ChartPage()
  ];
  var _mCurrentIndex = 0;





  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      floatingActionButton: FloatingActionButton(
        elevation: 0,
        child: const Icon(
          Icons.add,
          size: 30,
        ),
        onPressed: () {},
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: bottomNavItems,
        currentIndex: _mCurrentIndex,
        onTap: (va) {
          if (_mCurrentIndex != va) {
            _mCurrentIndex = va;
            setState(() {});
          }
        },
      ),
      body: IndexedStack(
        index: _mCurrentIndex,
        children: pages,
      ),
    );
  }
}
